PM_FUNC_NORM_ATTRIB SKILL:SkillLeechLife( SKILL_CALL:iCall, Int:id )
{
	switch( iCall )
	{
		case CALL_REGISTER: return SkillRegister( .Name = "Leech Life", .Type = TYPE_BUG, .callTypes = CALL_GIVE_DAMAGE, .PP = 15, .Charges = 10, .DelayTime = 5.0 );
		case CALL_HELP:     return SkillHelp( "Recieve health when you knife someone." );
		case CALL_GIVE_DAMAGE:
		{
			if ( g_iWeaponID == CSW_KNIFE )
			{
				new Int:iHealth = get_user_health( id );
				new Float:fMaxHealth, Int:iMaxHealth;
				pev( id, pev_max_health, fMaxHealth );
				iMaxHealth = floatround( fMaxHealth );

				new Int:iHeal = floatround( StatClamp( id, STAT_SPECIAL, g_fDamage / 4, g_fDamage / 2 ) );
				if ( iHeal && iHealth < iMaxHealth )
				{
					set_user_health( id, min( iHealth + iHeal, iMaxHealth ) );

					EffectScreenFlash( .iPlayer = id,
										.iRed = 255,
										.iGreen = 0,
										.iBlue = 0,
										.iAlpha = 200,
										.fTime = 0.5,
										.iFadeFlags = FFADE_MODULATE
									);

					return SKILL_USED;
				}
			}
		}
	}
	return SKILL_READY;
}

PM_FUNC_NORM_ATTRIB SKILL:SkillPinMissile( SKILL_CALL:iCall, Int:id )
{
	switch( iCall )
	{
		case CALL_REGISTER: return SkillRegister( .Name = "Pin Missile", .Type = TYPE_BUG, .callTypes = CALL_BIND_DOWN|CALL_ENTITY_TOUCH, .PP = 20, .Charges = 5, .DelayTime = 15.0 );
		case CALL_HELP:     return SkillHelp( "Fires a missile that launches and paralyzes enemies." );
		case CALL_BIND_DOWN:
		{
			SoundHit( id );

			EntitySkillCreate( .iPlayer = id,
								.iProperty = SEP_TOUCH|SEP_DAMAGE|SEP_KILL,
								.iDamage = StatClamp( id, STAT_ATTACK, 20, 40 ),
								.iMoveType = MOVETYPE_FLY,
								.iSolidType = SOLID_TRIGGER,
								.iModel = MODEL_ROCKET,
								.iSound = SOUND_HIT,
								.iSprite = SPRITE_EEXPLO,
								.bPlayerOrigin = true,
								.bPlayerAngles = true,
								.vMins = Vector:{-5.0,-5.0,-5.0},
								.vMaxs = Vector:{5.0,5.0,5.0},
								.iAimVelocity = StatClamp( id, STAT_SPEED, 450, 700 )
							);

			return SKILL_USED_PAUSE;
		}
		case CALL_ENTITY_TOUCH:
		{
			if ( is_user_alive( g_iVictim ) )
			{
				new Vector:vVelocity[3];
				EntityGetVelocity( g_iAttacker, vVelocity );
				vVelocity[2] = floatmax( vVelocity[2], 200.0 );
				EntitySetVelocity( g_iAttacker, vVelocity );

				StatusApply( .iPlayer = g_iVictim,
							.iInflictorID = id,
							.iStatus = STATUS_PARALYZE,
							.iAmount = StatClamp( id, STAT_SPECIAL, 3, 9 )
							);
			}

			return SKILL_READY;
		}
	}
	return SKILL_READY;
}

PM_FUNC_NORM_ATTRIB SKILL:SkillStringShot( SKILL_CALL:iCall, Int:id )
{
	switch( iCall )
	{
		case CALL_REGISTER: return SkillRegister( .Name = "String Shot", .Type = TYPE_BUG, .callTypes = CALL_TAKE_DAMAGE, .PP = 40, .Charges = 1, .DelayTime = 5.0 );
		case CALL_HELP:     return SkillHelp( "Chance to Slow enemies that attack you." );
		case CALL_TAKE_DAMAGE:
		{
			if ( StatChance( id, STAT_DEFENSE, 10, 50 ) )
			{
				new Int:iSlowTime = StatClamp( id, STAT_SPECIAL, 5, 15 );

				StatusApply( g_iAttacker,
							.iInflictorID = id, 
							.iStatus = STATUS_SLOW,
							.iAmount = iSlowTime
							);

				EffectBeamEnts( .iPlayer = 0,
								.iStartEnt = id,
								.iEndEnt = g_iAttacker,
								.iSprite = SPRITE_POISON,
								.iStartFrame = 0,
								.iFrameRate = 10,
								.fLife = 3.0,
								.iLineWidth = iSlowTime,
								.iNoiseAmp = 0,
								.iRed = 255,
								.iGreen = 255,
								.iBlue = 255,
								.iAlpha = 255,
								.iScrollSpeed = 10
							);

				return SKILL_USED;
			}
		}
	}
	return SKILL_READY;
}

PM_FUNC_NORM_ATTRIB SKILL:SkillTwinNeedle( SKILL_CALL:iCall, Int:id )
{
	switch( iCall )
	{
		case CALL_REGISTER: return SkillRegister( .Name = "Twin Needle", .Type = TYPE_BUG, .callTypes = CALL_BIND_DOWN, .PP = 20, .Charges = 10, .DelayTime = 10.0 );
		case CALL_HELP:     return SkillHelp( "Fires two needles that damage" );
		case CALL_BIND_DOWN:
		{
			SoundHit( id );

			new Int:iEntity, Vector:vVelocity[3], Vector:vAngle[3];
			new Float:fVecLen;
			new Int:iVelocity = StatClamp( id, STAT_SPEED, 450, 700 );
			for ( new Int:i; i < 2; i++ )
			{
				iEntity = EntitySkillCreate( .iPlayer = id,
											.iProperty = SEP_TOUCH|SEP_DAMAGE|SEP_KILL,
											.iDamage = StatClamp( id, STAT_ATTACK, 20, 40 ),
											.iMoveType = MOVETYPE_FLY,
											.iSolidType = SOLID_TRIGGER,
											.iModel = MODEL_ROCKET,
											.iSound = SOUND_HIT,
											.iSprite = SPRITE_BIGSPIT,
											.bPlayerOrigin = true,
											.bPlayerAngles = true,
											.vMins = Vector:{-5.0,-5.0,-5.0},
											.vMaxs = Vector:{5.0,5.0,5.0}
										);

				velocity_by_aim( id, iVelocity, vVelocity );

				vector_to_angle( vVelocity, vAngle );

				if ( i & 1 )
					vAngle[ 1 ] += 20.0;
				else
					vAngle[ 1 ] -= 20.0;

				angle_vector( vAngle, ANGLEVECTOR_FORWARD, vVelocity );

				EntitySetAngles( iEntity, vAngle );

				fVecLen = vector_length( vVelocity );
				vVelocity[0] = vVelocity[0] * iVelocity / fVecLen;
				vVelocity[1] = vVelocity[1] * iVelocity / fVecLen;
				vVelocity[2] = vVelocity[2] * iVelocity / fVecLen;
				EntitySetVelocity( iEntity, vVelocity );
			}

			return SKILL_USED_PAUSE;
		}
	}
	return SKILL_READY;
}

